<template>
	<view>
		<Details></Details>
		
		<view class="botBut">
			<uni-row gutter="20" class="butBox">
				<uni-col :span="24">
					<up-button @click="goChupin()" shape="circle" text="修改初评"></up-button>
				</uni-col>
			</uni-row>
		</view>
		
		
		<uni-popup ref="chupinPopup" background-color="#fff">
			<view class="formBox">
				<uni-section title="修改初评" type="line">
					<uni-card :is-shadow="false" margin="2px 10px 10px 10px">
						<view style="max-height: 70vh; overflow: auto;">
							<view class="topDetails">
								<p>风险事件评估值  5分</p>
								<p>当事人张三风险评估值  1.5分</p>
								<p>当事人李四风险评估值  1.5分</p>
								<p>根据以上评估情况，系统自动计算得出该风险的分值为： 6.5分 ，建议风险等级为： 低风险</p>
							</view>
							<uni-forms ref="chupinForm" :modelValue="chupinFormData" :rules="chupinRules" label-position="top">
								<uni-forms-item label="预估风险等级" required name="sex" label-width="120">
									<uni-data-checkbox v-model="chupinFormData.sex" :localdata="riskLevel" mode="list" />
								</uni-forms-item>
								<uni-forms-item label="评估意见">
									<uni-easyinput type="textarea" v-model="chupinFormData.introduction"
										placeholder="请输入自我介绍" />
								</uni-forms-item>
								<uni-forms-item label="附件">
								</uni-forms-item>
							</uni-forms>
						</view>
					</uni-card>
		
					<uni-row gutter="20" class="butBox">
						<uni-col :span="12">
							<up-button @click="closeChupin()" shape="circle" text="取消"></up-button>
						</uni-col>
						<uni-col :span="12">
							<up-button @click="submitChupi()" shape="circle" text="提交"></up-button>
						</uni-col>
					</uni-row>
				</uni-section>
			</view>
		</uni-popup>
		
	</view>
</template>

<script setup>
	import {
		ref
	} from 'vue';
	import Details from '@/pages/workspace/components/details.vue'
	
	// 向上交办
	const chupinPopup = ref(null)
	const chupinForm = ref(null)
	function goChupin() {
		chupinPopup.value.open('bottom')
	}
	
	function closeChupin() {
		chupinPopup.value.close()
	}
	const chupinFormData = ref({
		sex: '',
		introduction: '',
	})
	const chupinRules = ref({
		sex: {
			rules: [{
				required: true,
				errorMessage: '预估风险等级不能为空'
			}]
		},
	})
	const riskLevel = ref([{
		text: '暂无风险（归档到信息掌握）',
		value: 1
	}, {
		text: '低风险',
		value: 2
	}, {
		text: '中风险',
		value: 3
	}, {
		text: '高风险',
		value: 4
	}])
	function submitChupi() {
		chupinForm.value.validate().then(res => {
			console.log('success', res);
			uni.showToast({
				title: `校验通过`
			})
		}).catch(err => {
			console.log('err', err);
		})
	}
	
</script>

<style scoped>
	.botBut{
		width: 100%;
		background-color: #fff;
		position: fixed;
		left: 0;
		bottom: 0;
		z-index: 2;
	}
	.butBox{
		padding: 10px;
	}
	
	.topDetails{
		padding-bottom: 14px;
	}
	.topDetails p{
		line-height: 28px;
	}
</style>